Repository navigation
GH-55605: [R] Don't abort when comparing R extension types off the R thread - #55621
Open
csarushan1729 wants to merge 1 commit into
Open
csarushan1729 wants to merge 1 commit into
csarushan1729 wants to merge 1 commit into
Conversation
|
|
|
|
Member
|
I'm not entirely convinced by the answers to the "Was AI used for this PR?" section here |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale for this change
RExtensionType::ExtensionEquals()compares the extension name and the serialized metadata in C++. If those don't settle the comparison, it calls the R6ExtensionEquals()method throughSafeCallIntoR(). When that runs on a worker thread outsideRunWithCapturedR(),SafeCallIntoR()returns an error status.ExtensionEquals()then throws it as astd::runtime_error, nothing on that thread catches it, andstd::terminate()ends the R process.This happens when scanning a dataset whose parts use the same R extension type with different metadata, through both
dplyr::collect()andScanner$create(ds)$ToTable():What changes are included in this PR?
When R can't be called,
ExtensionEquals()now returnsfalseinstead of throwing. This is what the default RExtensionEquals()method would return in that case, because the serialized metadata differs. The scan then fails with the same ordinary R error as the single-threaded paths:Notes:
SafeCallIntoR()runs the R method directly, so this branch is never reached.RunWithCapturedR(), the R method still runs. If it raises an R error,RunWithCapturedR()re-raises that error as before.ExtensionEquals()can't be consulted, so two types with different serialized metadata compare as unequal there. Before this change, the same situation aborted the process.RExtensionType::ToString()already falls back the same way when R can't be called.Are these changes tested?
Yes. I added a test to
test-extension.R. It writes two IPC files whose column has the same extension type with different metadata, then checks thatcollect()andScanner$create(ds)$ToTable()raise an R error. Without the fix, this test aborts the R process (exit status 134).Locally on Linux (Ubuntu 26.04 under WSL), against a dev build of libarrow with Acero, Dataset and Parquet: all of
test-extension.Rpasses (FAIL 0 | WARN 0 | SKIP 0 | PASS 52).test-dataset.Randtest-safe-call-into-r.Rgive the same results with and without the change.Are there any user-facing changes?
Yes. Scanning such a dataset now raises an R error instead of ending the R session.
This PR contains a "Critical Fix". It fixes a crash (the R process is aborted) that occurs with documented API usage.
Was AI used for this PR?
In accordance to the AI generation guidelines, please disclose below whether and how AI was used in this PR.
PR code and description written by:
Reviewed before submission by: